﻿package model.business.bill;

import java.util.ArrayList;
import java.util.List;

import model.entity.Event;
import model.entity.MemberLevel;
import model.entity.product.Product;

public class Cart {

	private String idCustomer;

	private List<CartItem> items;
	

	public Cart(String idCustomer, List<CartItem> items) {
		super();
		this.idCustomer = idCustomer;
		this.items = items;
	}
	

	public String getIdCustomer() {
		return idCustomer;
	}


	public void setIdCustomer(String idCustomer) {
		this.idCustomer = idCustomer;
	}


	public List<CartItem> getItems() {
		return items;
	}


	public void setItems(List<CartItem> items) {
		this.items = items;
	}
	public void addCartItem(CartItem cartItem){
		if(items == null){
			items = new ArrayList<CartItem>();
			items.add(cartItem);
			return;
		}
		for(CartItem c: items){
			if(c.getProduct().getId() == cartItem.getProduct().getId()){
				c.setQuantity(cartItem.getQuantity() + c.getQuantity());
				return;
			}
		}
		items.add(cartItem);
	}
	public void deleteProduct(int idProduct){
		for(int i = 0; i < items.size(); i++){
			if(items.get(i).getProduct().getId() == idProduct){
				items.remove(i);
			}
		}
	}
	
	public Bill conevertToBill(Event listEvent) {
		return null;
	}

	public Bill conevertToBill(MemberLevel memberLevel, Event listEvent) {
		return null;
	}

}
